Repository navigation
feat(android): publish clickable, focusable, long-clickable and scrollable on raw snapshot nodes - #4633
Conversation
…lable on snapshot nodes A snapshot node carries hittable, which is true for a node that is clickable, focusable or focused. A reader that audits what an accessibility service is offered needs those apart: a node a screen reader can land on but cannot activate is hittable, and so is one it can activate. The Android reader already parses clickable, focusable and scrollable; this publishes them on the node. The snapshot helper now writes long-clickable, with both answers so a capture from an older helper is not read as a node that offers no long click.
|
The code change at d56b15a looks reasonable, but it has no live device evidence yet, so it needs one recorded run before merge. The PR changes the device-facing helper (a new XML attribute on every node) and the Android snapshot projection. The PR body has only three pasted node lines from an unnamed build, and its State section says the full check:affected, a helper-suite test and docs are not done. Nothing shows that the rebuilt helper serializes long-clickable on a device, that the default The four new keys are also written as explicit booleans on every node in the default projection, not only raw, at ui-hierarchy-builder.ts:481. Is that intended? Not blocking, and fine to take or leave: longClickable is a pure passive fact, so it fits in The failing check is |
clickable, focusable, longClickable and scrollable now travel as passive facts, so the raw projection carries them without new builder lines and longClickable drops out when the helper did not report it. The regular serializer omits all four, which keeps default snapshot --json unchanged: on a 500-node screen they would add tens of KB of mostly-false keys. Publishing them by default is a matter of removing that omission. A regular-projection case pins what the default route publishes for a visible and a fully clipped row.
The private evidence comment now says raw Android nodes serialize clickable, and the freshness signature comment no longer says the helper serializes no long-clickable.
They are field facts whose explicit false is the signal, the rule the digest already follows for editable and checked. A regular node carries none of them, so the digest is unchanged there; a raw node keeps what it reported, and the list needs no change if they are later published by default.
The helper writes long-clickable through a package-level method so its own suite, which runs without the Android runtime, can assert true and false.
|
@thymikee will add more details like snapshot etc and the suggested changes |
|
The code in 4451103 is ready: all six asks from the earlier review (#4633 (comment)) are now in this head, and the live-run evidence in the PR body covers them. Not blocking: The Coverage check (run 44093694330) is still red. This PR touches packages that job runs (platform-android, daemon response-views, command-runtime snapshot-unchanged, kernel types), so it may be related. Please share the failing assertion or threshold, or re-run it if it was a flake. Once Coverage is green or explained, nothing else holds this back, and there are no conflicts. The live run was at af7dd73, which differs from this head only by one doc comment in |
What
Raw Android snapshot nodes (
snapshot --raw) publish four accessibility facts next tohittable:clickable,focusableandscrollable: the reader already parsed these and dropped them at the projection.longClickable: the snapshot helper now writeslong-clickablewith both answers, so a capture served by an older helper reports nothing instead offalse.Default and
-isnapshots are unchanged: the four facts travel inAndroidPassiveNodeFactsand the regular projection leaves them out, so the builder gains no lines and defaultsnapshot --jsonoutput stays as it was.Why
hittableis true for a node that is clickable, focusable or focused. That is the right question for driving a screen, and it hides a difference an accessibility check needs: a node a screen reader can land on but cannot activate is hittable, and so is one it can activate.My case is a suite that tests native controls hosted in a React Native app (Compose inside React Native views). It asserts things like "the node carrying the control's name is the clickable one" and "a control with a long-press menu offers a long click". Today those few assertions need
adb shell uiautomator dump, which cannot run while the helper session holds the accessibility connection, so they live in a separate pass after the suite. Raw captures are enough for that.Review points
serializeRegularSnapshotPresentationNodeis the whole change.snapshot-private-evidence.tsnow says only raw Android nodes serializeclickable;snapshot-freshness/android.tsno longer says the helper writes nolong-clickable; theAndroidPassiveNodeFactscomment says which facts the regular projection leaves out.clickableByNodeIndex: still needed. Maestro's clickable-first ordering reads it on default snapshots, whose nodes do not carryclickable. The new default-route test shows the map populated while the nodes carry none of the four keys.longClickableis a passive fact with no conditional spread.SELECTOR_DIGEST_NODE_FIELDS: the four keys are added. An explicitfalsecarries meaning here, as it does forchecked; they cost nothing on default nodes, and a--rawget attrskeeps them. Say if you would rather leave them out.snapshots.mdhas one bullet per field and says absent means unavailable.long-clickabletrue and false.Checks
pnpm check:quickpasses.build:android-snapshot-helper.pnpm check:affected --run: format, lint and typecheck pass. On my machine the layering step stops in two tests that make a commit in a temporary repo, because my git config signs commits and has no key for them; the steps after it did not run locally.The Coverage failure on 4451103
Run 44093694330 failed on one test out of 20,774, in a package this change does not touch:
No threshold failed. The same file passes locally on this branch three times in a row (21 of 21 each). I cannot re-run the job from a fork, so the head now carries an empty commit to run the checks again.
Device evidence
sdk_gphone64_arm64(Pixel 9 profile), API 35af7dd7344723ecf29f87b81f4fceeca6650a8ec8. The head adds two commits after it: one that only changes a code comment, and an empty one to re-run the checks.package.jsonversion:0.21.39-devnitroui.example), ContextMenu screenBuild
Captures with the rebuilt helper
The first capture of the session installed the helper (
installReason: "missing"). The two captures below then reused it.snapshot --json --raw:141 nodes.
clickable,focusable,longClickableandscrollableare present on all 141.longClickableistrueon 1 node andfalseon 140.{"ref":"e87","identifier":"ctx-reset","label":"Reset the counters","type":"android.view.ViewGroup","clickable":true,"focusable":true,"longClickable":false,"scrollable":false,"hittable":true} {"ref":"e104","identifier":"ctx-accessible","label":"Message from Grace","type":"android.view.ViewGroup","clickable":false,"focusable":true,"longClickable":true,"scrollable":false,"hittable":true} {"ref":"e89","identifier":"ctx-scroll","type":"android.widget.ScrollView","clickable":false,"focusable":true,"longClickable":false,"scrollable":true,"hittable":true}ctx-resetctx-accessiblectx-resetctx-scrollsnapshot -i --json, with the same nodes:42 nodes. None of the 42 has any of the four keys.
{"ref":"e16","identifier":"ctx-reset","label":"Reset the counters","type":"android.view.ViewGroup","hittable":true} {"ref":"e29","identifier":"ctx-accessible","label":"Message from Grace","type":"android.view.ViewGroup","hittable":true} {"ref":"e18","identifier":"ctx-scroll","type":"android.widget.ScrollView","hittable":true}(Nodes trimmed to
ref,identifier,label,type, the four facts andhittable.)Capture with the released 0.21.37 helper
The CLI has no option for choosing the helper artifact, and its install policy (
missing-or-outdated) upgrades an installed 0.21.37 helper to the bundled one before it captures. So this capture calls the host through the option the code provides,snapshotAndroid(device, { helperArtifact })inpackages/platform-android/src/snapshot.ts, with the artifact set to the released v0.21.37 helper (its manifest and APK, sha256bfb470a1cc168e823766fedc62bf052b60b0fafa4527033e6fc7c709f8d1f317). The rebuilt helper was uninstalled first, so the host installed 0.21.37.After the run, the device reports
versionCode=21037,versionName=0.21.37. The process exited 0 and wrote nothing to stderr.141 nodes.
clickable,focusableandscrollableare present on all 141.longClickableis absent from all 141: the key is missing, notfalse.{"identifier":"ctx-reset","label":"Reset the counters","type":"android.view.ViewGroup","clickable":true,"focusable":true,"scrollable":false,"hittable":true} {"identifier":"ctx-accessible","label":"Message from Grace","type":"android.view.ViewGroup","clickable":false,"focusable":true,"scrollable":false,"hittable":true} {"identifier":"ctx-scroll","type":"android.widget.ScrollView","clickable":false,"focusable":true,"scrollable":true,"hittable":true}